﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Xml.Serialization;
using System.Text.RegularExpressions;

namespace BigPixels
{
	[Serializable]
	[XmlType(TypeName = "Cell")]    
	public class Cell
    {
        public Cell()
            : this(0, 0, Color.Empty)
        {
        }

        public Cell(int x, int y, Color c)
        {
            this.Position = new Point(x, y);
            this.Pixel = new PixelValue(c);
        }

        public Cell(int x, int y, Color c, Rectangle bounds)
        {
            this.Position = new Point(x, y);
            this.Pixel = new PixelValue(c);
            this.Bounds = bounds;
        }

		[XmlIgnore]
        public Point Position
        {
            get;
            set;
        }

		[XmlAttribute("X")]
		public int X
		{
			get
			{
				return this.Position.X;
			}
			set
			{
				this.Position = new Point(value, this.Position.Y);
			}
		}

		[XmlAttribute("Y")]
		public int Y
		{
			get
			{
				return this.Position.Y;
			}
			set
			{
				this.Position = new Point(this.Position.X, value);
			}
		}

		[XmlAttribute("Value")]
		public string Value
		{
			get
			{
				return this.Pixel.HexValue;
			}
			set
			{
				this.Pixel.HexValue = value;
			}
		}

		[XmlIgnore]
		public PixelValue Pixel
		{
			get;
			set;
		}

        [XmlIgnore]
        public Rectangle Bounds
        {
            get;
            set;
        }
    }
}
